//
//  DKHomeUnauthorizeBottomView.m
//  DanKU
//
//  Created by 吴斌 on 2023/10/4.
//

#import "DKHomeUnauthorizeBottomView.h"
@interface DKHomeUnauthorizeBottomView()
@property (nonatomic, strong)UILabel* dk_homePriceLab;
@property (nonatomic, strong)UILabel * dk_HomeDayLab;
@end
@implementation DKHomeUnauthorizeBottomView
-(instancetype)init{
    if(self == [super init]){
        self.backgroundColor = UIColor.whiteColor;
        [self dk_addSubView];
    }
    return self;
}
- (void)dk_addSubView{
    UILabel * dk_homeTitleLab = [[UILabel alloc] init];
    dk_homeTitleLab.textColor = DK_Hex(@"#333333");
    dk_homeTitleLab.font = DK_FONT_Medium(15);
    dk_homeTitleLab.text = @"Maximum loan amount up to";
    dk_homeTitleLab.textAlignment = NSTextAlignmentCenter;
    [self addSubview:dk_homeTitleLab];
    [dk_homeTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(0)));
        make.right.equalTo(@(DK_IsWidthScale(0)));
        make.top.equalTo(@(DK_IsWidthScale(60)));
        make.height.equalTo(@(DK_IsWidthScale(21)));
    }];
    UIView *dk_homeCenterPriceView = [[UIView alloc] init];
    dk_homeCenterPriceView.backgroundColor = [UIColor clearColor];
    [self addSubview:dk_homeCenterPriceView];
    [dk_homeCenterPriceView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(dk_homeTitleLab.mas_bottom).offset(DK_IsWidthScale(23));
        make.height.equalTo(@(DK_IsWidthScale(60)));
        make.centerX.equalTo(self);
    }];
    UILabel * dk_homeHeadPriceLab = [[UILabel alloc] init];
    dk_homeHeadPriceLab.textColor = DK_Hex(@"#4768FF");
    dk_homeHeadPriceLab.font = DK_FONT_Semibold(50);
    dk_homeHeadPriceLab.text = @"₹";
    [dk_homeCenterPriceView addSubview:dk_homeHeadPriceLab];
    [dk_homeHeadPriceLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(0)));
        make.top.equalTo(@(DK_IsWidthScale(0)));
        make.bottom.equalTo(@(DK_IsWidthScale(0)));
    }];
    self.dk_homePriceLab = [[UILabel alloc] init];
    self.dk_homePriceLab.textColor = DK_Hex(@"#333333");
    self.dk_homePriceLab.font = DK_FONT_Semibold(50);
    self.dk_homePriceLab.text = @"10,000";
    [dk_homeCenterPriceView addSubview:self.dk_homePriceLab];
    [self.dk_homePriceLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(dk_homeHeadPriceLab.mas_right).offset(DK_IsWidthScale(5));
        make.right.equalTo(@(DK_IsWidthScale(0)));
        make.top.equalTo(@(DK_IsWidthScale(0)));
        make.bottom.equalTo(@(DK_IsWidthScale(0)));
    }];
    
    UIImageView* dk_HomeBottomDayImgView = [[UIImageView alloc] init];
    dk_HomeBottomDayImgView.userInteractionEnabled = YES;
    dk_HomeBottomDayImgView.image = DK_GetImage(@"dk_HomeUnauthorizeTimeBg");
    [self addSubview:dk_HomeBottomDayImgView];
    [dk_HomeBottomDayImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(dk_homeCenterPriceView.mas_bottom).offset(DK_IsWidthScale(17));
        make.height.equalTo(@(DK_IsWidthScale(44)));
        make.width.equalTo(@(DK_IsWidthScale(170)));
        make.centerX.equalTo(self);
    }];
    UIImageView* dk_HomeDayHeadImgView = [[UIImageView alloc] init];
    dk_HomeDayHeadImgView.userInteractionEnabled = YES;
    dk_HomeDayHeadImgView.image = DK_GetImage(@"dk_HomeUnauthorizeTimeIcon");
    [dk_HomeBottomDayImgView addSubview:dk_HomeDayHeadImgView];
    [dk_HomeDayHeadImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(19)));
        make.height.equalTo(@(DK_IsWidthScale(26)));
        make.width.equalTo(@(DK_IsWidthScale(26)));
        make.centerY.equalTo(dk_HomeBottomDayImgView);
    }];
    self.dk_HomeDayLab = [[UILabel alloc] init];
    self.dk_HomeDayLab.textColor = DK_Hex(@"#333333");
    self.dk_HomeDayLab.font = DK_FONT_Regular(15);
    self.dk_HomeDayLab.text = @"91-180 days";
    [dk_HomeDayHeadImgView addSubview:self.dk_HomeDayLab];
    [self.dk_HomeDayLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(dk_HomeDayHeadImgView.mas_right).offset(DK_IsWidthScale(10));
        make.top.equalTo(@(DK_IsWidthScale(0)));
        make.bottom.equalTo(@(DK_IsWidthScale(0)));
    }];
    UIButton * dk_HomeStartBtn = [[UIButton alloc] init];
    [dk_HomeStartBtn setTitle:@"START" forState:UIControlStateNormal];
    [dk_HomeStartBtn setTitleColor:DK_Hex(@"#FFFFFF") forState:UIControlStateNormal];
    dk_HomeStartBtn.titleLabel.font = DK_FONT_Semibold(16);
    [dk_HomeStartBtn setBackgroundColor:DK_Hex(@"#4566FF")];
    dk_HomeStartBtn.layer.cornerRadius = DK_IsWidthScale(25);
    [dk_HomeStartBtn addTarget:self action:@selector(homeStart) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:dk_HomeStartBtn];
    [dk_HomeStartBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(30)));
        make.right.equalTo(@(-DK_IsWidthScale(30)));
        make.top.equalTo(dk_HomeDayHeadImgView.mas_bottom).offset(DK_IsWidthScale(76));
        make.height.equalTo(@(DK_IsWidthScale(50)));
    }];
    
    UIButton * dk_HomeAgreementBtn = [[UIButton alloc] init];
    [dk_HomeAgreementBtn setTitle:@"《Privacy Agreement》" forState:UIControlStateNormal];
    [dk_HomeAgreementBtn setTitleColor:DK_Hex(@"#CCCCCC") forState:UIControlStateNormal];
    dk_HomeAgreementBtn.titleLabel.font = DK_FONT_Regular(12);
    [dk_HomeAgreementBtn addTarget:self action:@selector(homeCheckAgreement) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:dk_HomeAgreementBtn];
    [dk_HomeAgreementBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(dk_HomeStartBtn.mas_bottom).offset(DK_IsWidthScale(70));
        make.height.equalTo(@(DK_IsWidthScale(17)));
    }];
}
-(void)layoutSublayersOfLayer:(CALayer *)layer{
    [super layoutSublayersOfLayer:layer];
    [self makeCornerOnTopleftRight:DK_IsWidthScale(60)];
}
//首页开始认证
- (void)homeStart{
    if(self.HomeStartAuthBlock){
        self.HomeStartAuthBlock();
    }
}
//查看隐私协议
- (void)homeCheckAgreement{
    if(self.CheckPrivacyBlock){
        self.CheckPrivacyBlock();
    }
}
- (void)updataBottomData{
    DKUserComplaintModel* userComplaintMdl = [DKGlobalHelper defaultManager].userComplaintMdl;
    if(userComplaintMdl){
        self.dk_homePriceLab.text = userComplaintMdl.total;
    }
}
@end
